/*
 * PlaylistInsertAction.java
 *
 * Created on April 8, 2006, 1:28 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.bff.mpd.musicjukebox.lib.actions;

import com.bff.mpd.utils.Utils;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import org.bff.javampd.MPDPlaylist;
import org.bff.javampd.exception.MPDConnectionException;
import org.bff.javampd.exception.MPDPlaylistException;
import org.bff.javampd.objects.MPDSong;

/**
 *
 * @author Bill
 */
public class PlaylistAddSongAction extends AbstractAction {

    private MPDPlaylist playlist;
    private MPDSong song;

    /** Creates a new instance of PlaylistInsertAction */
    public PlaylistAddSongAction(MPDPlaylist playlist, MPDSong song) {
        super(Utils.getMessage("ACTION_ADD_SONG_NAME"));
        this.playlist = playlist;
        this.song = song;
        putValue(Action.SHORT_DESCRIPTION, Utils.getMessage("ACTION_ADD_SONG_SHORT_DESC"));
        putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("/resources/slimserver/add.png")));
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        try {
            playlist.addSong(song);
        } catch (MPDConnectionException ex) {
            Logger.getLogger(PlaylistAddSongAction.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MPDPlaylistException ex) {
            Logger.getLogger(PlaylistAddSongAction.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
